package org.mushroomdb.lock.locktypes;

/**
 * @author Tomas
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class RegisterLock extends Lock {
    private long regId;
    
    public RegisterLock(long id, boolean exclusive, String userId, long regId){
        super(id,exclusive,userId);
        this.regId = regId;
    }
    

    /**
     * @return Returns the regId.
     */
    public long getRegId() {
        return this.regId;
    }
    /**
     * @param regId The regId to set.
     */
    public void setRegId(long regId) {
        this.regId = regId;
    }


    
    public boolean isPage() {
        return false;
    }


    
    public boolean isTable() {
          return false;
    }


    public boolean isRegister() {
        return true;
    }
    
    /* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    public boolean equals(Object obj) {
        if(obj instanceof RegisterLock){
            RegisterLock aRegisterLock = (RegisterLock) obj;
            return this.regId == aRegisterLock.regId;
        }
        else 
            return false;
    }
    
    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    public String toString() {
        return "Register ID: " + this.regId; 
     
    }
}
